<template>
	<view class="index">
		<view class="form-wrapper">
			<view class="item-wrapper">
				供应商：{{ form.supplierCode }}-{{form.supplierName}}
			</view>
		</view>
		<view class="form-wrapper">
			<view class="item-wrapper">
				<view class="label">
					城市仓：
				</view>
				<text>{{ form.cityCode }}{{ form.cityName }}.{{ form.pickupPointCode }}{{form.pickupPointName}}</text>
			</view>
			<view class="item-wrapper marginTop" v-for="(item,index) in form.vehicleList" :key="index">
				<view class="label">
					{{ index === 0 ? '停车位：':'' }}
				</view>
				<text>{{ item.parkingSpace }}</text>
				<text style="margin-left: 40rpx">{{ item.vehicleCode }}</text>
			</view>
		</view>
		<view class="product-item" v-for="(item,index) in form.itemList" :key="index">
			<view class="product-name-wrapper">
				<view class="productName">
					{{ index + 1 }}、{{ item.productName }}
				</view>
				<uni-icons type="right" size="16" color="#999999"></uni-icons>
			</view>
			<view class="info-wrapper">
				<text>货号：{{ item.productCode }}</text>
				<text class="bold">客户订货：{{ item.quantity }}件</text>
			</view>
			<view class="info-wrapper">
				<text class="bold">实际交货：</text>
				<input type="number" v-model="item.confirmQuantity" disabled placeholder="实际交货件数" class="input" />
				<text>件</text>
			</view>
		</view>
		<view v-if="form.confirmTime" class="form-wrapper tip-wrapper">
			<view>
				回单时间：{{ form.confirmTime }}
			</view>
			<view style="margin-top: 10upx;">
				操作员：{{ form.confirmBy }}
			</view>
		</view>
		<view class="images-wrapper">
			<view class="title-wrapper">
				<view class="title">
					回单小票
				</view>
			</view>
			<view class="product-image-list">
				<view class="item" v-for="(item,index) in imagelist" :key="index">
					<image @click="openPic(index)" :src="item+ '?imageView2/3/w/300/q/100'" class="product-image"
						mode="aspectFill">
					</image>
				</view>
			</view>
		</view>

		<view class="btn-wrapper">
			<view class="btn default" @click="goBack">
				返回
			</view>
			<view class="btn" v-if="$permissions.verify('app:shipment:add')" @click="goEdit">
				修改错漏
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {},
				imagelist: [],
				disabled: false
			}
		},
		onLoad(option) {
			this.getData(option.id)
		},
		methods: {
			async getData(id) {
				const data = await this.$api.get('/adm/supply/record/getInfo', {
					id: id
				})
				if (data.code === 200) {
					data.data.itemList = data.data.itemList.filter(item => {
						return item.confirmQuantity || item.confirmQuantity == '0'
					})
					this.imagelist = data.data.confirmImage.split(',')
					this.form = data.data;
					console.log(data.data)
				}
			},
			openPic(index) {
				uni.previewImage({
					urls: this.imagelist,
					current: index
				});
			},
			goEdit() {
				uni.navigateTo({
					url: '/subPage_receiptOrder/receipt?code=' + this.form.id
				})
			},
			goBack() {
				uni.navigateBack()
			}
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.index {
		height: 100%;
		padding-bottom: 150upx;
		overflow: auto;

		.form-wrapper {
			background-color: #ffffff;
			margin: 20upx 20upx 0 20upx;
			border-radius: 20upx;
			padding: 25upx;

			.item-wrapper {
				display: flex;
				align-items: center;

				.label {
					width: 140upx;
				}

				&.marginTop {
					margin-top: 20upx;
				}
			}
		}

		.product-item {
			background-color: #ffffff;
			margin: 20upx 20upx 0 20upx;
			border-radius: 20upx;
			padding: 25upx;

			.product-name-wrapper {
				display: flex;
				align-items: center;
			}

			.info-wrapper {
				margin-top: 20upx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.bold {
					font-weight: bold;
				}

				.input {
					flex: 1;
					font-weight: bold;
				}
			}
		}

		.images-wrapper {
			background-color: #ffffff;
			margin: 20upx 20upx 0 20upx;
			border-radius: 20upx;
			padding: 25upx;

			.title-wrapper {
				display: flex;
				align-items: center;

				.icon {
					margin-right: 5upx;
				}

				.title {
					height: 34upx;
					line-height: 34upx;
					font-size: 34upx;
					color: #222222;
					padding-left: 10upx;
					border-left: 8upx solid #555BFF;

					&.require::after {
						content: '*';
						color: red;
					}
				}
			}

			.product-image-list {
				display: flex;
				flex-wrap: wrap;
				margin-top: 26upx;

				.item {
					position: relative;
					width: 32%;
					height: 206upx;
					border-radius: 20upx;
					overflow: hidden;
					margin-left: 2%;
					margin-bottom: 20upx;

					&.add-item {
						display: flex;
						align-items: center;
						justify-content: center;
						background-color: #F0F0F0;
					}

					&:nth-child(3n+1) {
						margin-left: 0;
					}

					.product-image {
						width: 100%;
						height: 100%;
					}

					.del-wrapper {
						position: absolute;
						width: 50upx;
						height: 50upx;
						display: flex;
						align-items: center;
						justify-content: center;
						background-color: rgba(0, 0, 0, .5);
						top: 0;
						right: 0;
					}
				}
			}
		}

		.btn-wrapper {
			position: fixed;
			height: 100upx;
			width: 100%;
			bottom: 0;
			background-color: #ffffff;
			display: flex;
			align-items: center;
			z-index: 1;
			border-top: 1upx solid #efefef;

			.btn {
				display: flex;
				align-items: center;
				justify-content: center;
				flex: 1;
				height: 100%;
				background-color: #555BFF;
				color: #ffffff;

				&.default {
					color: #232323;
					background-color: #ffffff;
				}
			}
		}
	}
</style>